import 'package:trollee/app/core/core.dart';

/// 自定义图标按钮，默认大小为 24.w
class CustomIconButton extends StatelessWidget {
  CustomIconButton(
    this.iconData, {
    required this.onPressed,
    Key? key,
    this.color = AppColors.font_color_primary,
    double? size,
  })  : _size = size ?? AppDimens.dp24,
        super(key: key);

  CustomIconButton.s16(
    this.iconData, {
    required this.onPressed,
    Key? key,
    this.color = AppColors.font_color_primary,
  })  : _size = AppDimens.dp16,
        super(key: key);

  CustomIconButton.s24(
    this.iconData, {
    required this.onPressed,
    Key? key,
    this.color = AppColors.font_color_primary,
  })  : _size = AppDimens.dp24,
        super(key: key);

  final VoidCallback onPressed;
  final IconData iconData;
  final Color color;
  late final double _size;

  @override
  Widget build(BuildContext context) {
    return IconButton(
      constraints: BoxConstraints(
        minWidth: _size,
        minHeight: _size,
      ),
      onPressed: onPressed,
      color: color,
      padding: EdgeInsets.zero,
      iconSize: _size,
      icon: Icon(iconData),
    );
  }
}
